#!/bin/sh

gtktheme () {
	while IFS='=' read -r key value; do
		if [ "${key}" = "gtk-theme-name" ]; then
			printf '%s' "${value}"
			return 0
		fi
	done < "$HOME/.config/gtk-3.0/settings.ini"
}

old=$(cat ~/.cache/jgmenu/.last-gtktheme)
new=$(gtktheme)

if ! [ "${old}" = "${new}" ]; then
	printf '%b\n' "info: change gtk theme from ${old} to ${new}"
	jgmenu_run gtktheme
fi
